<script>
    function exist(data, arr) {
        l = 0
        r = arr.length - 1
        while (l <= r) {
            if (arr[l] == data || arr[r] == data)
                return true
            l++, r--
        }
        return false
    }
    alert(exist(2, [1, 2, 3]))
    alert(exist(0, [8, 9]))
</script>